{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" id="user_name" class="layui-input search" name="user_name" value="" placeholder="门店名字|电话|店址"/>
                        </div>
                        <div class="layui-col-md6 layui-input-inline search" style="margin-top: 5px">
                            <select name="s_status" lay-search="" lay-filter="types">
                                <option value="">不限状态</option>
                                <option value="1">正常</option>
                                <option value="2">冻结</option>
                            </select>
                        </div>
                        {if $agid != 10}
                        <div class="layui-col-md6 layui-input-inline search" style="margin-top: 5px">
                            <select name="typeid" lay-search="" lay-filter="types">
                                <option value="">不限分类</option>
                                {volist name='types' id='t'}
                                <option value="{$t.t_id}">{$t.t_name}</option>
                                {/volist}
                            </select>
                        </div>
                        <div class="layui-col-md6 layui-input-inline search" style="margin-top: 5px">
                            <select name="s_pp_id" lay-search="" id="type_pps">
                                <option value="">不限品牌</option>
                                {volist name='pps' id='pp'}
                                <option value="{$pp.pp_id}">{$pp.pp_name}</option>
                                {/volist}
                            </select>
                        </div>
                        {/if}
                        <div class="layui-col-md6 layui-input-inline search" style="margin-top: 5px">
                            <select name="s_p_id" lay-search="">
                                <option value="">不限装饰城</option>
                                {volist name='ps' id='p'}
                                <option value="{$p.p_id}">{$p.p_name}</option>
                                {/volist}
                            </select>
                        </div>
                        <div class="layui-col-md6 layui-input-inline search" style="margin-top: 5px">
                            <select name="s_qu" lay-search="">
                                <option value="">不限区域</option>
                                {volist name='qus' id='q'}
                                <option value="{$q.district_id}">{$q.district}</option>
                                {/volist}
                            </select>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="indexindex" class="layui-input">
                                <option value="">不限推荐1</option>
                                <option value="1">未推荐</option>
                                <option value="2">已推荐</option>
                            </select>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="indexindex2" class="layui-input">
                                <option value="">不限推荐2</option>
                                <option value="1">未推荐</option>
                                <option value="2">已推荐</option>
                            </select>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="indexindex3" class="layui-input">
                                <option value="">不限推荐3</option>
                                <option value="1">未推荐</option>
                                <option value="2">已推荐</option>
                            </select>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="indexindex4" class="layui-input">
                                <option value="">不限推荐4</option>
                                <option value="1">未推荐</option>
                                <option value="2">已推荐</option>
                            </select>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="indexindex5" class="layui-input">
                                <option value="">不限推荐5</option>
                                <option value="1">未推荐</option>
                                <option value="2">已推荐</option>
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="s_star" class="layui-input">
                                <option value="">不限星星数量</option>
                                <option value="0">没有星</option>
                                <option value="1">1星</option>
                                <option value="2">2星</option>
                                <option value="3">3星</option>
                                <option value="4">4星</option>
                                <option value="5">5星</option>
                            </select>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>

                <!--操作框开始-->
                <div class="col-sm-12">
                    <div class="input-group"  style="float: left">
                        <button class="btn btn-primary" type="button" onclick="wk.layer_show('新建', '{:url('newAdd')}')">
                            <i class="fa fa-plus"></i> 添加
                        </button>
                        <button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">
                            <i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">
                            <li><a  href="javascript:;" class="layuiBtn" data-type="ppll1">批量冻结</a></li>
                            <li><a  href="javascript:;" class="layuiBtn" data-type="ppll2">批量解冻</a></li>
                            {if $agid != 10}
                            <li><a  href="javascript:;" class="layuiBtn" data-type="ppll3">批量推荐1</a></li>
                            <li><a  href="javascript:;" class="layuiBtn" data-type="ppll4">批量取消推荐1</a></li>
                            <li><a  href="javascript:;" class="layuiBtn" data-type="ppll21">批量推荐2</a></li>
                            <li><a  href="javascript:;" class="layuiBtn" data-type="ppll22">批量取消推荐2</a></li>

                            {/if}
                        </ul>
                    </div>
                    <div class="input-group" style="float: left">
                        <button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">
                            <i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">
                            {if $agid != 10}
                            <li><a  href="javascript:;" class="layuiBtn" data-type="ppll31">批量推荐3</a></li>
                            <li><a  href="javascript:;" class="layuiBtn" data-type="ppll32">批量取消推荐3</a></li>
                            <li><a  href="javascript:;" class="layuiBtn" data-type="ppll41">批量推荐4</a></li>
                            <li><a  href="javascript:;" class="layuiBtn" data-type="ppll42">批量取消推荐4</a></li>
                            <li><a  href="javascript:;" class="layuiBtn" data-type="ppll51">批量推荐5</a></li>
                            <li><a  href="javascript:;" class="layuiBtn" data-type="ppll52">批量取消推荐5</a></li>

                            {/if}
                        </ul>
                    </div>
                </div>
                <!--操作框结束-->
                <div class="col-sm-12" style="width: 100%;">
                    <div class="input-group" style="color: red;width: 100%;">
                        <input type="text" disabled class="layui-input" value="推荐1({$wenan[0]})；推荐2({$wenan[1]})；推荐3({$wenan[2]})；" style="border:1px solid red;color: red;width: 100%;" />
                    </div>
                    <div class="input-group" style="color: red;width: 100%;">
                        <input type="text" disabled class="layui-input" value="推荐4({$wenan[3]})；推荐5({$wenan[4]})" style="border:1px solid red;color: red;width: 100%;" />
                    </div>
                </div>
            </div>
            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>
                    <script type="text/html" id="staBar">
                        <input type="checkbox" value="{{d.s_id}}"  lay-skin="switch"  lay-text="是|否" lay-filter="OnOff" {{ d.s_index == 2 ? 'checked' : '' }}  >
                    </script>
                    <script type="text/html" id="staBar2">
                        <input type="checkbox" value="{{d.s_id}}"  lay-skin="switch"  lay-text="是|否" lay-filter="OnOff2" {{ d.s_index2 == 2 ? 'checked' : '' }}  >
                    </script>
                    <script type="text/html" id="staBar3">
                        <input type="checkbox" value="{{d.s_id}}"  lay-skin="switch"  lay-text="是|否" lay-filter="OnOff3" {{ d.s_index3 == 2 ? 'checked' : '' }}  >
                    </script>
                    <script type="text/html" id="staBar4">
                        <input type="checkbox" value="{{d.s_id}}"  lay-skin="switch"  lay-text="是|否" lay-filter="OnOff4" {{ d.s_index4 == 2 ? 'checked' : '' }}  >
                    </script>
                    <script type="text/html" id="staBar5">
                        <input type="checkbox" value="{{d.s_id}}"  lay-skin="switch"  lay-text="是|否" lay-filter="OnOff5" {{ d.s_index5 == 2 ? 'checked' : '' }}  >
                    </script>

                    <!--图片显示模板-->
                    <!--<script type="text/html" id="imgTpl">-->
                        <!--<img src="{{d.pp_thumb}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"/>-->
                    <!--</script>-->
                    <!--操作模板-->
                    <script type="text/html" id="imgTpl2">
                        <ul class="aaasss">
                            {{#  layui.each(d.s_two_pic, function(index, item){ }}
                            <img src="{{item}}" data-original="{{item}}" class="table-img" onerror="this.src='/static/admin/images/head_default.gif'"  />
                            {{#  }); }}
                        </ul>
                    </script>
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.layer_show('编辑/详情', '{:url('newEdit')}?s_id={{d.s_id}}')" class="btn btn-primary btn-xs m-r-xs" title="编辑/详情">编辑/详情</a>
                        <a href="javascript:;" onclick="wk.layer_show('轮播图', '{:url('newBanner1')}?s_id={{d.s_id}}')" class="btn btn-primary btn-xs m-r-xs" title="轮播图">轮播图</a>
                        <a href="javascript:;" onclick="wk.layer_show('产品管理', '{:url('goods')}?s_id={{d.s_id}}')" class="btn btn-primary btn-xs m-r-xs" title="产品管理">产品管理</a>
                        <a href="javascript:;" onclick="wk.confirm('{{d.s_id}}','{:url('newDel')}','确定删除吗?')" class="btn btn-danger btn-xs m-r-xs" title="删除">删除</a>
                        {{# if(d.s_status == 1) { }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.s_id}}','{:url('down')}','确定冻结吗?')" class="btn btn-primary btn-xs m-r-xs" title="冻结">冻结</a>
                        {{# } }}
                        {{# if(d.s_status == 2) { }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.s_id}}','{:url('upup')}','确定解冻吗?')" class="btn btn-warning btn-xs m-r-xs" title="解冻">解冻</a>
                        {{# } }}
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Store/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 300]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
                {type: 'checkbox', fixed: 'left'},
                  {type:'numbers', width: 70, title: '序号'}
                , {field: 's_name', width: '', title: '门店名字', align: 'center'}
                , {field: 'pp_name', width: '', title: '所属品牌', align: 'center'}
                , {field: 'p_name', width: '', title: '所属装饰城', align: 'center'}
                , {field: 'district', width: '100', title: '所属区域', align: 'center'}
                , {field: 's_two_pic', width: '130', title: '推广图片', align: 'center',templet: '#imgTpl2'}
                , {field: 's_address', width: '', title: '门店地址', align: 'center'}
                , {field: 's_phone', width: '', title: '门店电话', align: 'center'}
                , {field: 's_open', width: '', title: '营业时间', align: 'center'}
                , {field: 's_sort', width: '110', title: '排序(可编辑)', align: 'center', edit: 'test'}
                , {field: 's_time', width: '', title: '发布时间', align: 'center'}
                , {field: 's_index',fixed: 'right', width: 80, title: '推荐1', align: 'center', templet: '#staBar'}
                , {field: 's_index2',fixed: 'right', width: 80, title: '推荐2', align: 'center', templet: '#staBar2'}
                , {field: 's_index3',fixed: 'right', width: 80, title: '推荐3', align: 'center', templet: '#staBar3'}
                , {field: 's_index4',fixed: 'right', width: 80, title: '推荐4', align: 'center', templet: '#staBar4'}
                , {field: 's_index5',fixed: 'right', width: 80, title: '推荐5', align: 'center', templet: '#staBar5'}
                , {fixed: 'right', width:'320', title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.table-img').viewer({
                    url: 'data-original',
                });
            }
        });
        //监听状态开关操作
        form.on('switch(OnOff)', function (obj) {
            var num = '';
            obj.elem.checked == true? num = 2: num = 1;
            //用户状态
            wk.status(this.value,num, '{:url("indexshow")}',obj);
        });
        //监听状态开关操作
        form.on('switch(OnOff2)', function (obj) {
            var num = '';
            obj.elem.checked == true? num = 2: num = 1;
            //用户状态
            wk.status(this.value,num, '{:url("indexshow2")}',obj);
        });
        //监听状态开关操作
        form.on('switch(OnOff3)', function (obj) {
            var num = '';
            obj.elem.checked == true? num = 2: num = 1;
            //用户状态
            wk.status(this.value,num, '{:url("indexshow3")}',obj);
        });
        //监听状态开关操作
        form.on('switch(OnOff4)', function (obj) {
            var num = '';
            obj.elem.checked == true? num = 2: num = 1;
            //用户状态
            wk.status(this.value,num, '{:url("indexshow4")}',obj);
        });
        //监听状态开关操作
        form.on('switch(OnOff5)', function (obj) {
            var num = '';
            obj.elem.checked == true? num = 2: num = 1;
            //用户状态
            wk.status(this.value,num, '{:url("indexshow5")}',obj);
        });
        //批量操作
        var $ = layui.$, active = {
            //批量导出订单
            ppll1:function () {
                wk.change(getIds(),'{:url('ppll')}','s_status',2);
            },
            ppll2:function () {
                wk.change(getIds(),'{:url('ppll')}','s_status',1);
            },
            ppll3:function () {
                wk.change(getIds(),'{:url('ppll')}','s_index',2);
            },
            ppll4:function () {
                wk.change(getIds(),'{:url('ppll')}','s_index',1);
            },
            ppll21:function () {
                wk.change(getIds(),'{:url('ppll')}','s_index2',2);
            },
            ppll22:function () {
                wk.change(getIds(),'{:url('ppll')}','s_index2',1);
            },
            ppll31:function () {
                wk.change(getIds(),'{:url('ppll')}','s_index3',2);
            },
            ppll32:function () {
                wk.change(getIds(),'{:url('ppll')}','s_index3',1);
            },
            ppll41:function () {
                wk.change(getIds(),'{:url('ppll')}','s_index4',2);
            },
            ppll42:function () {
                wk.change(getIds(),'{:url('ppll')}','s_index4',1);
            },
            ppll51:function () {
                wk.change(getIds(),'{:url('ppll')}','s_index5',2);
            },
            ppll52:function () {
                wk.change(getIds(),'{:url('ppll')}','s_index5',1);
            },

        };
        //监听单元格编辑---排序
        table.on('edit(testReload)', function(obj){
            var value = obj.value //得到修改后的值
                ,data = obj.data //得到所在行所有键值
                ,field = obj.field; //得到字段
            wk.change(data.s_id,"{:url('updateSort')}",field,value);
        });
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['s_id'])
            });
            return ids;
        }
        form.on('select(types)', function(data){
            $.ajax({
                url:"{:url('admin/Store/getDatas')}",
                dataType:"json",
                data:'type=1&t_id=' + data.value,
                type:'post',
                success:function(res){
                    var opt = '';
                    $.each(res.msg,function(key,vo){
                        opt = opt+"<option value="+vo.pp_id+">"+vo.pp_name+"</option>";
                    });
                    $("#type_pps").empty();
                    $("#type_pps").append('<option value="">---- 请选择品牌 ----</option>');
                    $("#type_pps").append(opt);
                    form.render('select');
                }
            })
        });
    });
</script>
</body>
</html>